package itcast.service.impl;

import itcast.dao.Drom_manageDao;
import itcast.dao.impl.Drom_manageDaoImpl;
import itcast.domain.Drom;
import itcast.domain.Studnet;
import itcast.service.Drom_manageService;

import java.util.List;
import java.util.Map;

public class Drom_manageServiceImpl implements Drom_manageService {
    Drom_manageDao drom_manageDao=new Drom_manageDaoImpl();
    //查找宿舍信息

    @Override
    public List<Drom> findAll() {
        return drom_manageDao.findAll();
    }
    //添加宿舍信息

    @Override
    public void addDrom(Drom drom) {
        drom_manageDao.addDrom(drom);
    }

    //删除宿舍数据

    @Override
    public void deleteDrom(String id) {
        drom_manageDao.delete(Integer.parseInt(id));
    }

    //删除选中宿舍数据

    @Override
    public void delDromSelected(String[] ids) {
        if(ids!=null &&  ids.length>0){
            //1.遍历数组
            for(String id :ids){
                //2.调用dao删除
                drom_manageDao.delete(Integer.parseInt(id));
            }
        }
    }

    //根据id查找数据

    @Override
    public Drom findDromById(String id) {
        return drom_manageDao.findByID(Integer.parseInt(id));
    }

    //修改drom数据

    @Override
    public void updateDrom(Drom drom) {
        drom_manageDao.update(drom);
    }

    //搜索数据

    @Override
    public List<Drom> findDrom_manageByDate(Map<String, String[]> condition) {
        return drom_manageDao.finddromByDate(condition);
    }


}
